package com.ls.bigdata.controller;

import com.ls.bigdata.DTO.Page;
import com.ls.bigdata.entity.IPInfo;
import com.ls.bigdata.servie.DataService;
import com.ls.bigdata.utils.Params;
import com.ls.bigdata.utils.R;
import com.ls.bigdata.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * @program: bit-data
 * @author: lishun
 * @create: 2021-09-23 21:19
 **/
@RestController
public class DataController {

    @Autowired
    private DataService dataService;

    /**
     * 表格
     * @param params
     * @return
     * @throws IOException
     */
    @GetMapping("/data/")
    public Result<Page> list(Params params) throws IOException {
        return R.ok(dataService.process(params));
    }

    /**
     * 图表接口
     * @return
     * @throws IOException
     */
    @GetMapping("/data/categoryShow")
    public  Map<String, List<IPInfo>> categoryShow() throws IOException {
        return dataService.categoryShow();
    }

    /**
     * 饼图
     * @return
     * @throws IOException
     */
    @GetMapping("/data/pie")
    public Result<Map> pieShow() throws IOException {
        return R.ok(dataService.pieChart());
    }
}
